class Solution {
    public String addStrings(String num1, String num2) {
        int add = 0;//竖式加法，储存进位
        int i = num1.length() - 1;
        int j = num2.length() - 1;
        StringBuffer sb = new StringBuffer("");

        while(i >= 0 || j >= 0 || add != 0){
            int x = i >= 0 ? num1.charAt(i) - '0' : 0;
            int y = j >= 0 ? num2.charAt(j) - '0' : 0;
            int res = x + y + add;
            add = res / 10;
            sb.append(res % 10);
            i--;
            j--;
        }
        return sb.reverse().toString();
    }
}